﻿using CleanArchitecture.Core.SharedKernel;
using Lucene.Net.Documents;
using Masuit.LuceneEFCore.SearchEngine;
using System;

namespace CleanArchitecture.Infrastructure.Entities.Business
{
    public partial class NewsItem : BaseEntity
    {
        //private ICollection<NewsComment> _newsComments;
        [LuceneIndex/*(Index = Field.Index.NOT_ANALYZED)*/]
        public int FKColumnId { get; set; }
        /// <summary>
        /// Gets or sets the news title
        /// </summary>
        [LuceneIndex]
        public string Title { get; set; }

        /// <summary>
        /// Gets or sets the short text内容摘要
        /// </summary>
        public string ContentOverView { get; set; }

        /// <summary>
        /// Gets or sets the Publisher of the News 新闻发布人(可为登录管理员名/也可自行修改)
        /// </summary>
        [LuceneIndex/*(Index = Field.Index.NOT_ANALYZED)*/]
        public string Publisher { get; set; }

        /// <summary>
        /// 发布审核人，需要与审核流程配合 
        /// </summary>
        public string Checker { get; set; }

        /// <summary>
        /// Gets or sets the 配置浏览权限 0-仅自已可见 1-仅后台管理员 2-所有人
        /// </summary>
        public EntityEnumConfig.WhoCanSee WhoCanSee { get; set; }

        /// <summary>
        /// 如果文章仅自己可见，保存发布者ID 见admin_user表，但仅限逻辑上，不能对数据库进行外键约束
        /// </summary>
        public string UserOrRoleId { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the news post comments are allowed 
        /// </summary>
        public EntityEnumConfig.YesorNo AllowComments { get; set; }

        /// <summary>
        /// MetaTitle For html seo search
        /// </summary>
        public string MetaTitle { get; set; }
        /// <summary>
        /// Gets or sets the meta keywords 文章标签等，后期SEO使用
        /// </summary>
        public string MetaKeyWords { get; set; }

        /// <summary>
        /// MetaDescription For html seo search
        /// </summary>
        public string MetaDescription { get; set; }
        
        /// <summary>
        /// 设置显示新闻/文章的主题封面图片 关联FileUpload表 分号分隔FileUploadId及图片访问Url
        /// </summary>
        public string CoverImageUrl { get; set; }
        /// <summary>
        /// Gets or sets the 文章正文 内容
        /// </summary>
        [LuceneIndex(IsHtml = true)]
        public string Contents { get; set; }

        /// <summary>
        /// Gets or sets the date and time of schedule task to start publish the news定时任务发布
        /// </summary>
        public DateTime? StartTaskTimeUtc { get; set; }
        /// <summary>
        /// 创建时间记录文章创建(写入数据库时间)，即便定时任务计划启用，在定时任务完成后也只会修改UpdateTime
        /// </summary>
        [LuceneIndex/*(Index = Field.Index.NOT_ANALYZED)*/]
        public DateTime CreatedOnTimeUtc { get; set; }
        public DateTime UpdatedOnTimeUtc { get; set; }
        public EntityEnumConfig.YesorNo IsActive { get; set; }
        /// <summary>
        /// 设置新闻/文章是否推荐置顶
        /// </summary>
        public EntityEnumConfig.YesorNo IsRecommend { get; set; }

        public int DisplayOrder { get; set; }
        #region 弃用 通过GenericAttribute表关联设置
        ///// <summary>
        ///// 设置显示新闻/文章的图片相册 关联FileUpload表 逗号分隔FileUploadId
        ///// 允许外链接图片，如果是外链接图片id为0
        ///// </summary>
        //public string ImagesIds { get; set; }
        ///// <summary>
        ///// 设置显示新闻/文章的图片相册 与ImagesIds对应 逗号分隔Url
        ///// </summary>
        //public string ImageUrls { get; set; }
        /// <summary>
        /// 设置显示新闻/文章的音频 关联FileUpload表 逗号分隔FileUploadId
        /// 允许外链接，如果是外链接音频id为0
        /// </summary>
        //public string AudioIds { get; set; }
        ///// <summary>
        ///// 设置显示新闻/文章的的音频 与ImagesIds对应 逗号分隔Url
        ///// </summary>
        //public string AudioUrls { get; set; }
        ///// <summary>
        ///// 设置显示新闻/文章的图片相册 关联FileUpload表 逗号分隔FileUploadId
        ///// 允许外链接图片，如果是外链接图片id为0
        ///// </summary>
        //public string VideoIds { get; set; }
        ///// <summary>
        ///// 设置显示新闻/文章的图片相册 与ImagesIds对应 逗号分隔Url
        ///// </summary>
        //public string VideoUrls { get; set; }
        ///// <summary>
        ///// 设置显示新闻/文章的图片相册 关联FileUpload表 逗号分隔FileUploadId
        ///// 允许外链接图片，如果是外链接图片id为0
        ///// </summary>
        //public string FileIds { get; set; }
        ///// <summary>
        ///// 设置显示新闻/文章的图片相册 与ImagesIds对应 逗号分隔Url
        ///// </summary>
        //public string FileUrls { get; set; }
        #endregion
        /// <summary>
        /// Gets or sets the news comments
        /// </summary>
        //public virtual ICollection<NewsComment> NewsComments
        //{
        //    get => _newsComments ?? (_newsComments = new List<NewsComment>());
        //    protected set => _newsComments = value;
        //}

        //public virtual Category Category { get; set; }
    }
}
